package com.example.node.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.node.R;
import com.example.node.bean.LifeStyleBean;

import java.util.List;

public class LifeStyleAdapter extends RecyclerView.Adapter<LifeStyleAdapter.ViewHolder> {

    private List<LifeStyleBean> mList;

    public LifeStyleAdapter(List<LifeStyleBean> mList) {
        this.mList = mList;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.layout_lifestyle_item, null);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
        LifeStyleBean lifeStyleBean=mList.get(i);
        viewHolder.tv_brf.setText(lifeStyleBean.getBrf());
        viewHolder.tv_text.setText(lifeStyleBean.getTxt());
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private ImageView iv_icon;
        private TextView tv_brf,tv_text;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            iv_icon=itemView.findViewById(R.id.iv_icon);
            tv_brf=itemView.findViewById(R.id.tv_brf);
            tv_text=itemView.findViewById(R.id.tv_text);
        }
    }
}
